#ifndef LIBACCENT_ALGORITHMS_FOLD_HPP
#define LIBACCENT_ALGORITHMS_FOLD_HPP

namespace accent
{
  // FIXME: Move somewhere else.
  struct const_true {
    template <typename Arg>
    bool operator ()(const Arg&) const { return true; }
  };

  template <typename Value, typename SinglePassRange,
            typename Combine, typename Condition = const_true>
  Value fold_left(Value initial, SinglePassRange range,
                  Combine combiner, Condition condition = Condition())
  {
    for (; !range.empty() && condition(initial); range.pop_front())
      initial = combiner(initial, range.front());
    return initial;
  }
}

#endif
